/*******************************************************************************
 * FilePath    : /Src/BSP/SPI.h
 * Version     : 1.0
 * Brief       :
 * Author      : AndrewHu
 * Company     : Shanghai MacroGiga Electronics CO.,Ltd
 * Email       : Hubinbo@macrogiga.com
 * Date        : 2020-04-03 15:06:14
 * LastEditors : AndrewHu
 * LastEditTime: 2022-02-16 15:45:26
 * Description :
 ******************************************************************************/
#ifndef __SPI_H__
#define __SPI_H__
/* Includes ------------------------------------------------------------------*/
#include <Includes.h>
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
#define ACTIVATE 0x50
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function ----------------------------------------------------------*/

/*******************************************************************************
 * Function    : SPI_WriteRead
 * Brief       :
 * Parameter   :
 * Returns     :
 * Date        : 2020-04-03 15:52:13
 * Description :
 ******************************************************************************/
unsigned char SPI_WriteRead(unsigned char SendData, unsigned char WriteFlag);
/*******************************************************************************
 * Function    : SPI_WriteBuf
 * Brief       :
 * Parameter   :
 * Returns     :
 * Date        : 2020-04-03 15:52:22
 * Description :
 ******************************************************************************/
unsigned char SPI_WriteBuf(unsigned char reg, unsigned char const *pBuf, unsigned char len);
/*******************************************************************************
 * Function    : SPI_ReadBuf
 * Brief       :
 * Parameter   :
 * Returns     :
 * Date        : 2020-04-03 15:52:33
 * Description :
 ******************************************************************************/
unsigned char SPI_ReadBuf(unsigned char reg, unsigned char *pBuf, unsigned char len);
/*******************************************************************************
 * Function    : IsIrqEnabled
 * Brief       :
 * Parameter   :
 * Returns     :
 * Date        : 2020-04-03 15:52:37
 * Description :
 ******************************************************************************/
char IsIrqEnabled(void);
/*******************************************************************************
 * Function    : SPIM_Init
 * Brief       : SPI
 * Parameter   :
 * Returns     :
 * Date        : 2020-04-03 15:50:40
 * Description :
 ******************************************************************************/
void SPIM_Init(SPI_TypeDef *SPIx, unsigned short spi_baud_div);

void mg_activate(unsigned char value);
void mg_writeReg(unsigned char reg, const unsigned char value);
void mg_readReg(unsigned char reg, unsigned char *value);
unsigned char mg_writeBuf(unsigned char reg, unsigned char const *pBuf, unsigned char len);
unsigned char mg_readBuf(unsigned char reg, unsigned char *pBuf, unsigned char len);
#endif
